package com.example.huahanshu2;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button=findViewById(R.id.submit);
        EditText n1=findViewById(R.id.getn1);
        EditText n2=findViewById(R.id.getn2);
        EditText n3=findViewById(R.id.getn3);
        EditText n4=findViewById(R.id.getn4);
        Button button1=findViewById(R.id.chose);
        Intent intent=new Intent(MainActivity.this,DrawHanShu.class);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String str=button1.getText().toString().trim();
                if(str.equals("坐标单位100")){
                    button1.setText("坐标单位10");
                    intent.putExtra("flag","2");
                }
                else{
                    button1.setText("坐标单位100");
                    intent.putExtra("flag","1");
                }
            }
        });





        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String num1=n1.getText().toString().trim();
                String num2=n2.getText().toString().trim();
                String num3=n3.getText().toString().trim();
                String num4=n4.getText().toString().trim();
                if(num1.isEmpty()){
                    intent.putExtra("num1","0");
                }
                else {
                    intent.putExtra("num1",num1);
                }

                if(num2.isEmpty()){
                    intent.putExtra("num2","0");
                }
                else {
                    intent.putExtra("num2",num2);
                }

                if(num3.isEmpty()){
                    intent.putExtra("num3","0");
                }
                else {
                    intent.putExtra("num3",num3);
                }

                if(num4.isEmpty()){
                    intent.putExtra("num4","0");
                }
                else {
                    intent.putExtra("num4",num4);
                }

                EditText log=findViewById(R.id.getn5);
                String num5=log.getText().toString().trim();
                if (num5.isEmpty()){
                    intent.putExtra("num5","0");
                }
                else {
                    intent.putExtra("num5",num5);
                }


                EditText beishu=findViewById(R.id.getbeishu);
                EditText dishu=findViewById(R.id.getdishu);
                EditText zhishubeishu=findViewById(R.id.getzhishubeishu);
                String bs=beishu.getText().toString().trim();
                String ds=dishu.getText().toString().trim();
                String zsbs=zhishubeishu.getText().toString().trim();
                if(bs.isEmpty())
                {
                    intent.putExtra("bs","0");
                }
                else
                    {intent.putExtra("bs",bs);}
                if(ds.isEmpty())
                {
                    intent.putExtra("ds","0");
                }
                else{intent.putExtra("ds",ds);}
                if(zsbs.isEmpty())
                {
                    intent.putExtra("zsbs","0");
                }
                else{intent.putExtra("zsbs",zsbs);}


                EditText sinb=findViewById(R.id.sinbeishu);
                EditText sinc=findViewById(R.id.sincanshubeishu);
                EditText cosb=findViewById(R.id.cosbeishu);
                EditText cosc=findViewById(R.id.coscanshubeishu);
                EditText tanb=findViewById(R.id.tanbeishu);
                EditText tanc=findViewById(R.id.tancanshubeishu);
                String sin_b=sinb.getText().toString().trim();
                String sin_c=sinc.getText().toString().trim();
                String cos_b=cosb.getText().toString().trim();
                String cos_c=cosc.getText().toString().trim();
                String tan_b=tanb.getText().toString().trim();
                String tan_c=tanc.getText().toString().trim();
                //sin
                if(sin_b.isEmpty()){
                    intent.putExtra("sin_b","0");
                }
                else{
                    intent.putExtra("sin_b",sin_b);
                }
                if(sin_c.isEmpty()){
                    intent.putExtra("sin_c","0");
                }
                else{
                    intent.putExtra("sin_c",sin_c);
                }
                //cos
                if(cos_b.isEmpty()){
                    intent.putExtra("cos_b","0");
                }
                else{
                    intent.putExtra("cos_b",cos_b);
                }
                if(cos_c.isEmpty()){
                    intent.putExtra("cos_c","0");
                }
                else{
                    intent.putExtra("cos_c",cos_c);
                }
                //tan
                if(tan_b.isEmpty()){
                    intent.putExtra("tan_b","0");
                }
                else{
                    intent.putExtra("tan_b",tan_b);
                }
                if(tan_c.isEmpty()){
                    intent.putExtra("tan_c","0");
                }
                else{
                    intent.putExtra("tan_c",tan_c);
                }

                EditText cos=findViewById(R.id.twocos);
                EditText tan=findViewById(R.id.twotan);
                String cos_=cos.getText().toString().trim();
                String tan_=tan.getText().toString().trim();
                if(cos_.isEmpty()){intent.putExtra("tcos","0");}
                else{
                    intent.putExtra("tcos",cos_);
                }
                if(tan_.isEmpty()){intent.putExtra("ttan","0");}
                else{
                    intent.putExtra("ttan",tan_);
                }

                EditText getesin=findViewById(R.id.getesin);
                EditText getecos=findViewById(R.id.getecos);
                String esin=getesin.getText().toString().trim();
                String ecos=getecos.getText().toString().trim();
                if(esin.isEmpty()){
                    intent.putExtra("esin","0");
                }
                else{
                    intent.putExtra("esin",esin);
                }
                if(ecos.isEmpty()){
                    intent.putExtra("ecos","0");
                }
                else{
                    intent.putExtra("ecos",ecos);
                }


                startActivity(intent);


            }
        });
    }
}